package com.juzipi.demo.config;


import com.juzipi.demo.tools.Result;
import org.apache.shiro.authz.UnauthenticatedException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionAdvice {

    //捕捉 ShiroException 所有异常
    //返回无权限信息
    @ExceptionHandler(UnauthenticatedException.class)
    public Result handle401(){
        return Result.fail(401,"请先登录才能访问");
    }



    @ExceptionHandler(UnauthorizedException.class)
    public Result handle403(){
        return Result.fail(403,"抱歉您没有访问此路径的权限");
    }


//    @ExceptionHandler()
}
